import 'package:get/get.dart';
import 'package:vape_xe/utils/utils.dart';

class WithdrawDetailsController extends GetxController {
  /// 响应式成员变量
  final withdrawDetails = <String, dynamic>{}.obs;

  /// 成员变量
  late String id;

  /// 事件
  String getStatusString() {
    return switch (withdrawDetails['state']) {
      0 => 'Waiting for user authentication'.tr,
      1 => 'Pending'.tr,
      2 => 'Withdraw Successful'.tr,
      3 => 'Withdraw failed'.tr,
      4 => 'Time out or cancel'.tr,
      _ => ''
    };
  }

  /// 生命周期
  @override
  void onReady() async {
    super.onReady();
    id = Get.parameters['withdrawId'] ?? '';
    await Request().get('/userCashRecord/getInfo', {'cashId': id}).then((result) {
      withdrawDetails.value = result['result'];
    });
  }
}
